def save_error(taskname, msg_list):
    file_name = f'{taskname}-ERROR.txt'
    f = open(file_name, 'w')
    for line in msg_list:
        f.write(f'{line}\n')
    f.flush()
    f.close()
    return file_name


def save_check_point(taskname, checkpoint):
    file_name = f'{taskname}.txt'
    f = open(file_name, 'w')
    f.write( f'{checkpoint}\n')
    f.flush()
    f.close()
    return file_name

import dbm
import dbm.dumb
import os
tmp_dir = os.path.join(os.getcwd(), ".tmp")
if not os.path.exists(tmp_dir):
    os.makedirs(tmp_dir)
db = dbm.open(os.path.join(tmp_dir, "cache"), 'c')
def is_success(flow_name, key):
    return db.get(f"{flow_name}-{key}") is not None

def set_success(flow_name, key):
    db[f"{flow_name}-{key}"] = "1"
    
import atexit
def close_db():
    if db:
        db.sync()
        db.close()
atexit.register(close_db)